package nimble.maxwoods.regx;/**
 * @description:
 * @authoer: Max Woods
 * @create:2018/7/2 15:04
 **/


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
 *@auther: Max Woods
 *@create:2018/7/2 15:04
 **/
public class RegX2 {

    private static final Logger logger=LoggerFactory.getLogger(RegX.class);

    public static void main(String[] args)
    {
        logger.info("=======开始匹配=======");
        final Pattern fileFilterPattern = Pattern.compile(".*\\.(zip|mp4|exe|css|gif)(\\?)*.*$",Pattern.CASE_INSENSITIVE);
        final Pattern NoDataPagePattern = Pattern.compile(".*(check.jsp|contact.jsp|yewufanchou.jsp|reg.jsp|/hyd/|chat.jsp|fazhanlishi.jsp|/lpai/|info.jsp).*$",Pattern.CASE_INSENSITIVE);
        final Pattern DataPagePattern = Pattern.compile(".*((.jsp)?\\?G=.*|(.jsp)?\\?T=.*\\&G=.*|(.jsp)?\\?P=.*\\&G=.*|(.jsp)?\\?OBY=.*\\&G=.*)",Pattern.CASE_INSENSITIVE);
        List<String> urls=new ArrayList<>();
        urls.add("http://img.shouxi.com/partner/hxgq.exe");
        urls.add("http://img.shouxi.com/partner/hxgq.gif?id=23434");
        //===================================================================
        urls.add("http://www.huayicang.com/hxgq/xpai/index.jsp?G=25621");
        for(String url:urls)
        {
            if(fileFilterPattern.matcher(url).matches())
            {
                logger.info("文件过滤:{}",url);
            }
            if(NoDataPagePattern.matcher(url).matches())
            {
                logger.info("非数据提取url:{}",url);
            }
            if(DataPagePattern.matcher(url).matches())
            {
                logger.info("数据提取url:{}",url);
            }
        }
    }
}
